<!--
 * @Description: 粘滞定位
 * @Author: rendc
 * @Date: 2025-09-16 14:45:35
 * @LastEditors: rendc
 * @LastEditTime: 2025-09-16 15:07:26
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>粘滞定位</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    body {
      height: 100vh;

    }

    .app {
      height: 200px;
      border: 1px solid red;
      /* overflow: auto; */
      /* 默认值 */
      overflow: scroll;
    }

    .btn,
    .btn2 {
      position: sticky;
      border-radius: 50%;
      width: 50px;
      height: 50px;
      border: 1px solid red;
      text-align: center;
      line-height: 50px;
      /* bottom: 50px; */
      top: 50px;
      right: 10px;
      background-color: red;
    }

    .btn {
      z-index: 100;
    }

    .btn2 {
      top: 55px;
      z-index: 10;
    }
  </style>
</head>

<body>
  <div class="app">
    <br>1<br>2<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>3<br>
    <div class="btn">点我</div>
    <div class="btn2">点2</div>
    <br>1<br>2<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>3<br>
  </div>
</body>

</html>